package com.hr.humanresource.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.hr.humanresource.domain.SysUserVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hr.common.annotation.Log;
import com.hr.common.core.controller.BaseController;
import com.hr.common.core.domain.AjaxResult;
import com.hr.common.enums.BusinessType;
import com.hr.common.core.domain.entity.SysUser;
import com.hr.humanresource.service.humanresourceService;
import com.hr.common.utils.poi.ExcelUtil;
import com.hr.common.core.page.TableDataInfo;

/**
 * 员工管理Controller
 * 
 * @author ruoyi
 * @date 2024-07-14
 */
@RestController
@RequestMapping("/manage/humanresource")
public class humanresourceController extends BaseController
{
    @Autowired
    private humanresourceService sysUserService;

    /**
     * 查询员工管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:humanresource:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysUser sysUser)
    {
        startPage();
        List<SysUserVO> list = sysUserService.selectSysUserList(sysUser);
        return getDataTable(list);
    }


    /**
     * 获取员工管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:humanresource:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return success(sysUserService.selectSysUserByUserId(userId));
    }

    /**
     * 新增员工管理
     */
    @PreAuthorize("@ss.hasPermi('manage:humanresource:add')")
    @Log(title = "员工管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysUser sysUser)
    {
        return toAjax(sysUserService.insertSysUser(sysUser));
    }

    /**
     * 修改员工管理
     */
    @PreAuthorize("@ss.hasPermi('manage:humanresource:edit')")
    @Log(title = "员工管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysUserVO sysUser)
    {
        return toAjax(sysUserService.updateSysUser(sysUser));
    }

    /**
     * 删除员工管理
     */
    @PreAuthorize("@ss.hasPermi('manage:humanresource:remove')")
    @Log(title = "员工管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(sysUserService.deleteSysUserByUserIds(userIds));
    }


}
